<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<!--标准mui.css-->
		<link href="../css/app.css" rel="stylesheet" />
		<link href="../cssmui/mui.min.css" rel="stylesheet">
		<script src="../mui/mui.min.js"></script>
		<script src="../js/app.js"></script>

		<script src="../mui/common.js"></script>	
		<script src="../js/jsondb.js"></script>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">备份</h1>
		</header>
		<div class="mui-content">
			
			<button id="bt5">重置进货状态</button><br>
			<button id="bt6">清空交易清单</button><br>
			<button id="bt1">字典初始化</button><br>
			<button id="bt2">查询</button><br>
		</div>
		
		<script type="text/javascript">
			mui.plusReady(function() {
				mui.init();
				mui.ready(function() {
					var _db1 = new XCDBHelp();
					
					mui('.mui-content').on('tap', '#bt2', function() {
						look();
					});
					
					mui('.mui-content').on('tap', '#bt5', function() {
						var _db1 = new XCDBHelp('tb_io');

						_db1.batchreplace(function(rs) {
							for(var k in rs) {

								if(rs[k]['status'] > 1) {
									rs[k]['status'] = 1
									console.log(rs[k]._idkey)
								}

							}
							return rs;
						});
						var _db2 = new XCDBHelp('tb_i02');
						var _db3 = new XCDBHelp('tb_store_mon');
						var _db4 = new XCDBHelp('tb_journal');
						var _db5 = new XCDBHelp('tb_myacct');
						var _db6 = new XCDBHelp('tb_tradeacct');
						_db2.clear();
						_db3.clear();
						_db4.clear();
						_db5.clear();
						_db6.clear();
						console.log('设置完成')
						//					setTimeout(function(){
						//						_db1.recover()
						//					},1000)	
					});
					mui('.mui-content').on('tap', '#bt6', function() {
						var _db0 = new XCDBHelp('tb_io');
						var _db1 = new XCDBHelp('tb_io1');
						var _db2 = new XCDBHelp('tb_io2');
						var _db3 = new XCDBHelp('tb_price_mon');
						var _db4 = new XCDBHelp('tb_store_mon');
						var _db5 = new XCDBHelp('tb_journal');
						var _db6 = new XCDBHelp('tb_myacct');
						var _db7 = new XCDBHelp('tb_tradeacct');
						var _db8 = new XCDBHelp('tb_settle');
						var _db9 = new XCDBHelp('tb_store');
						var _db10 = new XCDBHelp('tb_checknum');

						_db0.clear();
						_db1.clear();
						_db2.clear();
						_db3.clear();
						_db4.clear();
						_db5.clear();
						_db6.clear();
						_db7.clear();
						_db8.clear();
						_db9.clear();
						_db10.clear();
						console.log('设置完成')
						//					setTimeout(function(){
						//						_db1.recover()
						//					},1000)	
					});

					mui('.mui-content').on('tap', '#bt1', function() {
						var tb_types = new XCDBHelp('tb_types');

						var tmp = {}
						tmp.key = '物品类型'
						tmp.objs = [{
							value: '1',
							text: '面膜'
						}, {
							value: '2',
							text: '保湿水'
						}, {
							value: '3',
							text: '防晒霜'
						}]
						console.log('设置完成')
					});
					//tb_types.push(tmp)

					//					setTimeout(function(){
					//						_db1.recover()
					//					},1000)	
				});

			})

			function afterPlusReady() {}

			function look() {
				var tio1 = new XCDBHelp('tb_io1');
				//遍历所有缺货销售的单据明细
				var qs = tio1.where({
					"lacknum(": 0,
					"pors": "s1"
				}).getList();
				console.log('setIo1Lack2，qs：' + JSON.stringify(qs));
			}
		</script>
	</body>

</html>